package cn.bone.ou.vote.param;

import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

public class VoteParam {

/**
 {
    range: 1,									//使用默认值1,页面上下拉选择的时候显示内容为当前小区的名字
    title: "测试投票",							//议事标题
    startTime: "2019-07-10 12:12",				//开始时间
    endTime: "2019-07-20 18:00",				//结束时间
    content: "这里是投票的详情内容",			//议事详情
    extras: [									//附件数组
        {
            extraType: 1,						//附件类型(1:文件,2:文章)
            detailId: 1							//附件id
        },
        {
            extraType: 2,						//附件类型(1:文件,2:文章)
            detailId: 3							//附件id
        }
    ],
    items: [									//事项数组
        {
            title: "我们小区要不要垃圾分类?",	//事项描述
            itemType: 1,						//类型(1:单选,2:多选)
            chooseNum: 1,						//最多可选数量(单选时为1,多选时不能超过选项总数)
            options: [							//选项数组.最多能设置4项
                {
                    answerOption: "A",			//选项标识
                    answerContent: "要"			//选项内容
                },
                {
                    answerOption: "B",
                    answerContent: "不要"
                }
            ]
        },
        {
            title: "小区每天巡逻时间",
            itemType: 2,
            chooseNum: 4,
            options: [
                {
                    answerOption: "A",
                    answerContent: "早上8点"
                },
                {
                    answerOption: "B",
                    answerContent: "下午2点"
                },
                {
                    answerOption: "C",
                    answerContent: "晚上8点"
                },
                {
                    answerOption: "D",
                    answerContent: "凌晨2点"
                }
            ]
        }
    ]
 }

*/

    @Data
    public static class AddParam{
        @NotNull
        private Integer communityId;
        @NotNull
        private String voteJson;
    }

    @Data
    public static class ModifyParam{
        @NotNull
        private Integer voteId;
        @NotNull
        private String voteJson;
    }


    @Data
    public static class VoteJson{
        @NotNull(message = "投票范围不能为空")
        private Integer range;
        @NotNull(message = "议事标题不能为空")
        private String title;
        @NotNull(message = "开始时间不能为空")
        private String startTime;
        @NotNull(message = "结束时间不能为空")
        private String endTime;
        @NotNull(message = "议事详情不能为空")
        private String content;
        @Size(min = 0,max = 6,message = "最多只能添加6个附件")
        @Valid
        private List<VoteExtraJson> extras;
        @Valid
        @Size(min = 1,max = 10,message = "投票事项最少添加1个,最多添加10个")
        private List<VoteItemJson> items;
    }

    @Data
    public static class VoteExtraJson{
        @NotNull(message = "附件类型不能为空")
        private Integer extraType;
        @NotNull(message = "附件编号不能为空")
        private Integer detailId;
    }

    @Data
    public static class VoteItemJson{
        @NotNull(message = "事项描述不能为空")
        private String title;
        @NotNull(message = "事项类型不能为空")
        private Integer itemType;
        @NotNull(message = "选择数量不能为空")
        private Integer chooseNum;
        @Valid
        @Size(min = 2,max = 4,message = "最少添加2个选项,最多添加4个选项")
        private List<optionJson> options;
    }

    @Data
    public static class optionJson{
        @NotNull(message = "选项标识不能为空")
        private String answerOption;
        @NotNull(message = "选项内容不能为空")
        private String answerContent;
    }

    @Data
    public static class ListParam {
        @NotNull
        private Integer communityId;
        @NotNull
        private Integer start;
        @NotNull
        private Integer num;
        private String title;
        private Integer state;
    }

    @Data
    public static class PublishParam {
        @NotNull
        private Integer voteId;
    }

    @Data
    public static class UnpublishParam{
        @NotNull
        private Integer voteId;
    }

    @Data
    public static class StopParam{
        @NotNull
        private Integer voteId;
    }

    @Data
    public static class DetailParam{
        @NotNull
        private Integer voteId;
    }

    @Data
    public static class DeleteParam {
        @NotNull
        private Integer voteId;
    }

    @Data
    public static class ResultDetailParam {
        @NotNull
        private Integer voteId;
    }

    @Data
    public static class MemberDetailParam {
        @NotNull
        private Integer voteId;
        @NotNull
        private Integer start;
        @NotNull
        private Integer num;
    }

    @Data
    public static class MemberVoteDetailParam {
        @NotNull
        private Integer voteId;
        @NotNull
        private Integer userId;
    }
}
